<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../../common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>费用更正</title>
<jsp:include page="../../../common/head.jsp">
	  <jsp:param name="_useCalendar" value="true"/>
</jsp:include>
<script language="javascript">
	function saveData(){
		if($("#updateFeeTarget").attr("checked")!="checked"&&$("#updateFeeType").attr("checked")!="checked")
		{
			alert("请选择要进行更正的数据项");
			return;
		}
		xj.ignoreNotExistElment = true;
		var objarr = new Array(
			["targetId","updateFeeTarget","function","ok"],
			["feeTypeName","updateFeeType","function","ok"]
		);
		if(xj.CheckAll(objarr))
		{
			if(confirm("确认保存？"))
			{
				document.getElementById("form1").submit();
			}
		}
	}
	function updateFeeTarget()
	{
		if($("#updateFeeTarget").attr("checked")=="checked")
		{
			if($("#targetId").find("option:selected").val()!="")
			{
				return "ok";
			}
			else
				return "请选择费用发生对象";
		}
		return "ok";
	}
	function updateFeeType()
	{
		if($("#updateFeeType").attr("checked")=="checked")
		{
			if($("#feeTypeName").val()!="")
			{
				return "ok";
			}
			else
				return "请选择费用类型";
		}
		return "ok";
	}
	//变换对象
	function selectFeeTarget(suffix)
	{
		var feeTarget = $("#feeTarget"+suffix).find("option:selected").val();
		var areaId = $("#areaId").val();
		_d(areaId);
		var tmp = parseInt(Math.random()*1000000+1);
		var url = 'showFeeTargetFeeDetail.do?feeTarget='+feeTarget+"&areaId="+areaId;
		
		$.get(url, {},function (data, textStatus){
			$("#targetId"+suffix).html(data);
		});
	}
	//选择费用类型
	function selectFeeType(suffix){
		var code = ModalWindow("jump.do?path=listDictComm.do&toJsp=/jsp/common/code/lst_code_dict.jsp&kindId=004",640,480);
		if(code!=null)
		{
			var str = code.split("#");
			$("#feeTypeId"+suffix).val(str[0]);
			$("#feeTypeName"+suffix).val(str[1]);
		}
	}
	//返回
	function goback()
	{
		window.top.close();
	}

	//将select的option的text放入hidden
	function selectOption(objSelect,hiddenId)
	{
		$("#"+hiddenId).val($(objSelect).find("option:selected").text());
	}

	$.ready = function()
	{
		$(".selectValueFilter").bind("keyup", function(){
			var selectObj = $(this).next();
			var val = $(this).val();
			$(selectObj).find("option").each(function(i){
				if($(this).text().indexOf(val)!=-1)
					$(this).attr("selected","selected");
			})
		});
	}
	
</script>

</head>
<body>
<form name="form1" id="form1"  action="updateFeeUpdate.do" method="post">
	<input type="hidden" id="areaId" name="feeDetail.areaId" value="${feeReport.areaId}"/>
	<div id="body_div">
	<w:ShowTitle name="费用更正">
	<w:TitleButton funcName="保存" onClickFunction="saveData()" urlImg="${ctx}/images/main/save.png"/>
	<w:TitleButton funcName="返回" onClickFunction="goback()" urlImg="${ctx}/images/main/back.png"/>
	</w:ShowTitle>
	<div id="body_content">
	<input type="hidden" name="feeIds" value="${param.feeIds}"/>
	<table width="100%">
		<c:if test="${param.updateType eq 'feeReport'}">
            <tr>
              <td width="120" class="right_align">编号</td>
              <td class="left_align">
				${feeReport.feeReportCode}
			  </td>
              <td width="80" class="right_align">地区</td>
              <td class="left_align">
				${feeReport.areaName}
			  </td>
              <td width="80" class="right_align">事业部</td>
              <td class="left_align">
				${feeReport.areaDeptName}
			  </td>
			 </tr>
		</c:if>
		<c:if test="${param.editTarget ne 'false'}">
			<tr>
              <td class="right_align">发生对象(<input type="checkbox" name="updateFeeTarget" id="updateFeeTarget" value="1" class="checkbox" checked="checked"/>修改)</td>
              <td class="left_align">
              	<w:select name="feeTarget" styleId="feeTarget" onchange="selectFeeTarget('')">
					<w:option optionLabel="请选择" optionValue=""></w:option>
					<w:option optionLabel="地区人员" optionValue="地区人员"></w:option>
					<w:option optionLabel="地区办事处" optionValue="地区办事处"></w:option>
					<w:option optionLabel="销售分线" optionValue="销售分线"></w:option>
				</w:select>
              </td>
              <td class="right_align">对象名称
              </td>
              <td class="left_align" colspan="3">
              	<input type="hidden" id="targetName" name="targetName"/>
              	<input type="text" class="selectValueFilter"/>
              	<select name="targetId" id="targetId" onchange="selectOption(this,'targetName')"><option value="">请选择</option></select>
              </td>
			  </tr>
			 </c:if>
			  <tr>
              <td class="right_align" width="120">费用类别(<input type="checkbox" name="updateFeeType" id="updateFeeType" value="1" class="checkbox" checked="checked"/>修改)</td>
              <td class="left_align" colspan="5">
              	<input type="hidden" id="feeTypeId" name="feeTypeId" value="${feeTypeId}"/>
              	<input type="text" name="feeTypeName" id="feeTypeName" class="inputQry" readonly="readonly" onclick="selectFeeType('')"/>
              </td>
            </tr>
          </table>
	</div>
	</div>	
</form>
</body>
</html> 